package it.afs.worklog.application.form.admin;

import org.apache.wicket.PageParameters;
import org.apache.wicket.RestartResponseException;

import it.afs.worklog.application.BasePage;
import it.afs.worklog.application.ErrorPage;
import it.afs.worklog.application.LoginPage;
import it.afs.worklog.application.WorkLogSession;

public abstract class AdminPage extends BasePage
{
	public AdminPage()
	{
		super();
		
		setVersioned(false);

		if(!WorkLogSession.getCurrentSession().isLoggedUser())
			throw new RestartResponseException(LoginPage.class);
		
		if(!WorkLogSession.getCurrentSession().getLoggedUser().isAdmin())
			throw new RestartResponseException(new ErrorPage(getString("page.admin.denied")));
	}

	public AdminPage(PageParameters parameters)
	{
		super(parameters);
		
		setVersioned(false);
		
		if(!WorkLogSession.getCurrentSession().isLoggedUser())
			throw new RestartResponseException(LoginPage.class);
		
		if(!WorkLogSession.getCurrentSession().getLoggedUser().isAdmin())
			throw new RestartResponseException(new ErrorPage(getString("page.admin.denied")));
	}
}